<template>
  <div>
    <el-form :inline="true" :model="formInline" class="demo-form-inline">
      <el-form-item label="签约状态">
        <el-select v-model="formInline.status" clearable placeholder="请选择">
          <el-option label="生效中" :value="4"></el-option>
          <el-option label="已过期" :value="5"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="签约机构">
        <el-select v-model="formInline.jid" clearable placeholder="请选择">
          <el-option v-for="item in jiGo"  :label="item.name" :value="item.id"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="签约团队">
        <el-select v-model="formInline.tid" clearable placeholder="请选择">
          <el-option v-for="item in tuanDui"  :label="item.name" :value="item.id"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="签约服务包">
        <el-select v-model="formInline.fid" clearable placeholder="请选择">
          <el-option v-for="item in fwb"  :label="item.name" :value="item.id"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="活动时间">
        <el-col :span="11">
          <el-date-picker type="date" value-format="yyyy-MM-dd" placeholder="选择日期" v-model="formInline.start" style="width: 100%;"></el-date-picker>
        </el-col>
        <el-col class="line" :span="2">-</el-col>
        <el-col :span="11">
          <el-date-picker type="date" value-format="yyyy-MM-dd" placeholder="选择日期" v-model="formInline.end" style="width: 100%;"></el-date-picker>
        </el-col>
      </el-form-item>
      <el-form-item label="关键字">
        <el-input v-model="formInline.name" clearable placeholder="请输入关键字"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="findPage()">查询</el-button>
      </el-form-item>
    </el-form>
    <el-table
        :data="tableData"
        stripe
        style="width: 100%"
        @selection-change="handleSelectionChange">
        >
      <el-table-column
          type="selection"
          width="55">
      </el-table-column>
      <el-table-column
          prop="bianhao"
          label="编号"
          width="180">
      </el-table-column>
      <el-table-column
          prop="name"
          label="签约人姓名"
          width="180">
      </el-table-column>
      <el-table-column
          prop="sfz"
          label="身份证号"
          width="180">
      </el-table-column>
      <el-table-column
          prop="phone"
          label="手机号码"
          width="180">
      </el-table-column>、
      <el-table-column
          prop="status"
          label="签约状态"
          width="180">
        <template slot-scope="scope">
          <el-tag v-if="scope.row.status==4" type="success">生效中</el-tag>
          <el-tag v-if="scope.row.status==5" type="danger">已过期</el-tag>
        </template>
      </el-table-column>
      <el-table-column
          prop="yname"
          label="签约医生团队"
          width="180">
      </el-table-column>
      <el-table-column
          prop="fname"
          label="签约服务包"
          width="180">
      </el-table-column>
      <el-table-column
          prop="xiugaisj"
          label="最后修改时间"
          width="180">
      </el-table-column>
      <el-table-column
          label="操作">
        <template slot-scope="scope">
          <el-button size="mini" @click="xq(scope.row.id)">查看详情</el-button>
          <el-button size="mini" type="danger" @click="bianji(scope.row.id)">续约</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="pageNum"
        :page-sizes="[10, 20, 50, 100]"
        :page-size="pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total">
    </el-pagination>
  </div>
</template>
<script >
export default {
  data() {
    return {
      tableData:[],
      jiGo:[],
      tuanDui:[],
      fwb:[],
      formInline:{},
      total:0,
      pageNum:1,
      pageSize:10,
      multipleSelection:[],

    }
  },
  methods: {
    findPage(){
      this.axios.post(`http://localhost:9000/agency/qianyue/findAllJl?pageNum=${this.pageNum}&pageSize=${this.pageSize}`,this.formInline).then(res=>{
        this.tableData = res.data.data.records;
        this.total = res.data.data.total;
      })
    },
    findJiGo(){
      this.axios.post(`http://localhost:9000/agency/jigo/findAll`).then(res=>{
        this.jiGo = res.data.data;
      })
    },
    findTuanDui(){
      this.axios.post(`http://localhost:9000/agency/tuandui/findAll`).then(res=>{
        this.tuanDui = res.data.data;
      })
    },
    findFwb(){
      this.axios.post(`http://localhost:9000/agency/fwb/findAll`).then(res=>{
        this.fwb = res.data.data;
      })
    },
    xq(id){
      this.$router.push({path:'/yxq',query:{id:id}})
    },
    bianji(id){
      this.$router.push({path:'/xy',query:{id:id}})
    },
    handleSizeChange(val) {
      this.pageSize = val;
      this.findPage();
    },
    handleCurrentChange(val) {
      this.pageNum = val;
      this.findPage();
    },
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },

  },
  created() {
    this.findPage();
    this.findJiGo();
    this.findTuanDui();
    this.findFwb();
  }
}
</script>

<style>

</style>